import request from '@/utils/request';
import type { BaseBeanModel, ResponsePageData, ResponseBaseData, QueryParamModel } from '@/api/model/baseModel';
import type { downloadParam } from '@/utils/download-util';
import { downloadSysFile } from '@/utils/download-util';
const basePath = '/appsys/sysuploadfiles';
/** 导入记录表 */
export interface SysUploadFilesDto extends BaseBeanModel {
  /** 文件名 */
  fileName?: string;
  /** 模块名 */
  moduleName?: string;
  /** 状态 */
  status?: string;
  /** 文件类型 */
  fileType?: string;
  /** 文件大小 */
  fileSize?: string;
  /** 总条数 */
  allCount?: number;
  /** 成功条数 */
  successCount?: number;
  /** 失败条数 */
  errorCount?: number;
  /** 异常信息 */
  errorInfo?: string;
  /** 备注 */
  remark?: string;
}

/** 获取分页数据 */
export function listSysUploadFilesByPage(param: QueryParamModel): Promise<ResponsePageData<SysUploadFilesDto>> {
  return request.post(`${basePath}/find-list-by-page/v1`, param);
}

/** 根据id加载数据 */
export function getSysUploadFiles(id: string): Promise<ResponseBaseData<SysUploadFilesDto>> {
  return request.get(`${basePath}/get/${id}/v1`);
}

/** 保存表单数据 */
export function saveSysUploadFiles(form: SysUploadFilesDto): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/save/v1`, form);
}

/** 根据id集合删除数据 */
export function delSysUploadFiles(ids: [string]): Promise<ResponseBaseData<any>> {
  return request.delete(`${basePath}/delete-by-ids/v1`, { data: ids });
}

/** 导出Excel */
export function exportExcel(param: any) {
  const download = {
    url: `${basePath}/export-data/v1`,
    data: param,
    method: 'post'
  } as downloadParam;
  return downloadSysFile(download);
}
